﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DTO;
using BUS;
using Utility;

public partial class Doanh_Nghiệp_DN_PhieuDeal : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            LoaData();
        }
    }


    private void LoaData()
    {
        PagerV2_8_1.PageSize = 10;
        Criteria c = new Criteria();
        int total = 0;
        PhieuDealCollection phieuDealCollection =
            Phieu_Deal_BUS.Get(c.Criter, PagerV2_8_1.CurrentIndex, PagerV2_8_1.PageSize,
            PhieuDealColumns.ID.ToString(), OrderDirection.ASC.ToString(), out total);
        Repeater1.DataSource = phieuDealCollection;
        Repeater1.DataBind();

        PagerV2_8_1.ItemCount = total;
    }

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem ||
    e.Item.ItemType == ListItemType.Item)
        {
            Phieu_Deal_DTO phieuDeal = (Phieu_Deal_DTO)e.Item.DataItem;

            HyperLink hyp_MaPH = (HyperLink)e.Item.FindControl("hyp_MAPHIEU");
            //HyperLink hyp_MaMH = (HyperLink)e.Item.FindControl("hyp_MATHANG");

            Literal tinh_trang = (Literal)e.Item.FindControl("l_tinhtrang");
            TinhTrang_Phieu_DTO tinhTrang = TinhTrang_Phieu_BUS.GetByID(phieuDeal.MaTinhTrang_Phieu);
            Literal don_Hang = (Literal)e.Item.FindControl("l_DonHang");
            CTHoaDon_DTO donHang = CTHoaDon_BUS.GetByID(phieuDeal.MaCTHD);

            tinh_trang.Text = tinhTrang.TenTinhTrang;
            don_Hang.Text = donHang.ID.ToString();
            //hyp_MaPH.Text = phieuDeal.MaPhieu.ToString();
            //hyp_MaMH.Text = phieuDeal.MaMH.ToString();
            HyperLink hplsua = (HyperLink)e.Item.FindControl("hpl_Edit");
            hplsua.NavigateUrl = "~/Doanh Nghiệp/DN_SuaPhieuDeal.aspx?ID=" + phieuDeal.ID.ToString();
        }
    }
}
